﻿
Sys.Application.add_load(BeginRequestHandler);
function BeginRequestHandler() {
    $("#ctl00_MainContent_gvJobList input[id*='chkboxSelectAll']:checkbox").click(function () {
        //Check/uncheck all checkboxes in list according to main checkbox 
        $("#ctl00_MainContent_gvJobList input[id*='chkDelete']:checkbox").attr('checked', $(this).is(':checked'));

        var len = $("input[type=checkbox][id*=chkDelete]:checked").length
        var length = parseInt(len);
        var m = 0;
        if (length == 0) {
            $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", true);
        }
        else {
            $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", false);
        }
    });
    $("#ctl00_MainContent_gvJobList input[id*='chkDelete']:checkbox").click(
function () {
    //alert('disableButton' + $("input[type=checkbox][id*=chkDelete]:checked").length);

    var len = $("input[type=checkbox][id*=chkDelete]:checked").length
    var length = parseInt(len);
    var m = 0;
    if (length == 0) {
        $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", true);
    }
    else {
        $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", false);
    }
});
    $("#ctl00_MainContent_btnNo").click(
function () {
    //alert('disableButton' + $("input[type=checkbox][id*=chkDelete]:checked").length);

    var len = $("input[type=checkbox][id*=chkDelete]:checked").length
    var length = parseInt(len);
    var m = 0;
    if (length == 0) {
        $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", true);
    }
    else {
        $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", false);
    }
});

    $('#ctl00_MainContent_ddlSearchBy').change(function () {
        if ($(this).val() == "Deadline") {
            $('#ctl00_MainContent_lblMessage').text('i.e. 10 (in days)');
        }
        else {
            $('#ctl00_MainContent_lblMessage').text('');
        }
    });
    if ($('#ctl00_MainContent_txtSearch').val() == "" || $('#ctl00_MainContent_txtSearch').val() == null || $('#ctl00_MainContent_txtSearch').val() == 'Write text and press enter') {
        var watermark = 'Write text and press enter';
        $('#ctl00_MainContent_txtSearch').blur(function () {
            if ($(this).val().length == 0)
                $(this).val(watermark).addClass('watermark');
        }).focus(function () {
            if ($(this).val() == watermark)
                $(this).val('').removeClass('watermark');
        }).val(watermark).addClass('watermark');
    }
}


//Sys.Application.add_load(BeginRequestHandler);
//function BeginRequestHandler() {
//    $("#<%=gvJobList.ClientID%> input[id*='chkboxSelectAll']:checkbox").click(function () {
//        //Check/uncheck all checkboxes in list according to main checkbox 
//        $("#<%=gvJobList.ClientID%> input[id*='chkDelete']:checkbox").attr('checked', $(this).is(':checked'));

//        var len = $("input[type=checkbox][id*=chkDelete]:checked").length
//        var length = parseInt(len);
//        var m = 0;
//        if (length == 0) {
//            $('#<%=btnDeleteSeledRows.ClientID %>').attr("disabled", true);
//        }
//        else {
//            $('#<%=btnDeleteSeledRows.ClientID %>').attr("disabled", false);
//        }
//    });
//    $("#<%=gvJobList.ClientID%> input[id*='chkDelete']:checkbox").click(
//        function () {
//            //alert('disableButton' + $("input[type=checkbox][id*=chkDelete]:checked").length);

//            var len = $("input[type=checkbox][id*=chkDelete]:checked").length
//            var length = parseInt(len);
//            var m = 0;
//            if (length == 0) {
//                $('#<%=btnDeleteSeledRows.ClientID %>').attr("disabled", true);
//            }
//            else {
//                $('#<%=btnDeleteSeledRows.ClientID %>').attr("disabled", false);
//            }
//        });
//    $("#<%=btnNo.ClientID%>").click(
//function () {
//    //alert('disableButton' + $("input[type=checkbox][id*=chkDelete]:checked").length);

//    var len = $("input[type=checkbox][id*=chkDelete]:checked").length
//    var length = parseInt(len);
//    var m = 0;
//    if (length == 0) {
//        $('#<%=btnDeleteSeledRows.ClientID %>').attr("disabled", true);
//    }
//    else {
//        $('#<%=btnDeleteSeledRows.ClientID %>').attr("disabled", false);
//    }
//});

//    $('#<%=ddlSearchBy.ClientID %>').change(function () {
//        if ($(this).val() == "Deadline") {
//            $('#<%=lblMessage.ClientID %>').text('i.e. 10 (in days)');
//        }
//        else {
//            $('#<%=lblMessage.ClientID %>').text('');
//        }
//    });
//    if ($('#<%= txtSearch.ClientID %>').val() == "" || $('#<%= txtSearch.ClientID %>').val() == null || $('#<%= txtSearch.ClientID %>').val() == 'Write text and press enter') {
//        var watermark = 'Write text and press enter';
//        $('#<%= txtSearch.ClientID %>').blur(function () {
//            if ($(this).val().length == 0)
//                $(this).val(watermark).addClass('watermark');
//        }).focus(function () {
//            if ($(this).val() == watermark)
//                $(this).val('').removeClass('watermark');
//        }).val(watermark).addClass('watermark');
//    }
//}